<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8" name="viewport" content="width=device-width,initial-scale=1.0">
	<title>用户管理</title>
    <!-- Bootstrap core CSS -->
    <link href="/static/bootstrap/css/bootstrap2.min.css" rel="stylesheet">
	<link href="/static/fullcalendar/fullcalendar.min.css" rel="stylesheet">
	<link href="/static/fullcalendar/fullcalendar.print.min.css" rel="stylesheet" media="print">
	<link href="/static/jquery-ui-1.10.4.custom/css/base/jquery-ui-1.10.4.custom.min.css" rel="stylesheet">
	<link href="/static/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css" rel="stylesheet">
	<link href="/static/fullcalendar/lib/cupertino/jquery-ui.min.css" rel="stylesheet">
	<link href="/static/artDialog/css/ui-dialog.css" rel="stylesheet">
	<link href="/static/wickedpicker/dist/wickedpicker.min.css" rel="stylesheet">
	<script src="/static/jquery-ui-1.10.4.custom/js/jquery-1.10.2.js"></script>
	<script src="/static/fullcalendar/lib/jquery.min.js"></script>
	<script src="/static/fullcalendar/lib/jquery-ui.min.js"></script>
	<script src="/static/fullcalendar/lib/moment.min.js"></script>
	<script src="/static/fullcalendar/fullcalendar.js"></script>
	<script src="/static/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
	<script src="/static/artDialog/dist/dialog-min.js"></script>
	<script src="/static/bootstrap/js/bootstrap.min.js"></script>
	<script src="/static/wickedpicker/dist/wickedpicker.min.js"></script>
	<script src="/static/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
	<script src="/static/bootstrap-datepicker/dist/locales/bootstrap-datepicker.zh-CN.min.js"></script>
	<style>
		body{
			margin:40px 40px;
			padding:0;
			background:white;
			font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
			font-size: 14px;
		}
	</style>
	<script>
        {% if del_info %}
            alert("{{ del_info }}");
        {% endif %}
        //--删除好友
	function colDelete(deleteId) {
		if(confirm("确认删除？")) {
            $.ajax({
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/colleague/colleague_delete",//url
                data:"{\"colleague_id\":\""+deleteId+"\"}",
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    if (result == "Success") {
                        alert("SUCCESS");
                        $("#btnSubmit").attr("disabled", true);
                    }
                    ;

                },
                error: function () {
                    alert("删除成功！");
                    window.location.reload();
                }
            });
        }
	};

	function colAdd() {
	    var nickName = $('#nickname').val();
		if(confirm("确认添加？")) {
            $.ajax({
                type: "POST",//方法类型
                dataType: "text",//预期服务器返回的数据类型
                url: "/colleague/colleague_add",//url
                data:"{\"nickName\":\""+nickName+"\"}",
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    if (result == "SUCCESS") {
                        alert("添加成功！");
                        window.location.reload();
                    }
                    else{
                        alert("好友信息错误！");
                        window.location.reload();
                    }

                },
                error: function () {
                    alert("好友信息出现错误！");
                    window.location.reload();
                }
            });
        }
	};
    </script>
</head>
<body style="background: url('/static/imgs/background.jpg');background-repeat:no-repeat;background-size:cover">
    <!-- 导航栏 -->
    <nav class="navbar navbar-fixed-top navbar-inverse" style="height: 40px;" >
      <div class="container">
        <div class="navbar-header" style="height: 40px;">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="/user/to_user_index_page">用户管理</a></li>
            <li><a href="#" data-toggle="modal"  data-target="#updateUserInfo">管理员 {{ session["username"] }}</a></li>
            <li><a href="/admin/admin_logout">注销</a></li>
          </ul>
        </div><!-- /.nav-collapse -->
      </div><!-- /.container -->
    </nav><!-- /.navbar -->


    <script>
	//搜索用户
	function selectUser() {
	    var user_name = $('#select_user_name').val();
        window.location.href='/admin/user_select?user_name='+user_name;
	};
    </script>

    <!-- 导航栏结束 -->

    <br>

    <div class="container">
    <div class="col-sm-12" >
    <button type="button" id="btnAdd" data-toggle="modal" data-target="#selectModal"  class="btn btn-primary">查找用户</button>
    <table id="selectRes" class="table table-hover">
        {%  if colleague_list %}
                <h3>查找结果</h3>
            {% for item in colleague_list %}
                <tr>
                    <td>{{ item.username }}</td>
                    <td>{{ item.password }}</td>
                    <td>{{ item.nickname }}</td>
                    <td>{{ item.sex }}</td>
                    <td>{{ item.email }}</td>
                    <td>{{ item.phone }}</td>
                    <td>
                        <a href="/admin/user_delete?user_id={{ item.id }}"><button type="button" class="btn btn-primary">删除用户</button></a>
                    </td>
                </tr>
            {% endfor %}
        {% endif %}
    </table>


    <br/>
    <!-- 所有用户列表 -->
    <table class="table table-hover">
        {%  if user_info_list %}
                <tr>
                    <td>用户名称</td>
                    <td>密码</td>
                    <td>昵称</td>
                    <td>性别</td>
                    <td>邮箱</td>
                    <td>电话</td>
                    <td>操作</td>
                </tr>
            {% for item in user_info_list %}
                <tr>
                    <td>{{ item.username }}</td>
                    <td>{{ item.password }}</td>
                    <td>{{ item.nickname }}</td>
                    <td>{{ item.sex }}</td>
                    <td>{{ item.email }}</td>
                    <td>{{ item.phone }}</td>
                    <td>
                        <a href="/admin/user_delete?user_id={{ item.id }}"><button type="button" class="btn btn-primary">删除用户</button></a>
                    </td>
                </tr>
            {% endfor %}
        {% else %}
            <a href="#">暂无用户</a>
        {% endif %}
    </table>
    </div>
    </div>




<!-- 搜索用户 -->
<div class="modal fade" id="selectModal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	                <h4 class="modal-title" id="myModalLabel">查找同事</h4>
	            </div>
     <div class="modal-body">
					  <div class="form-group">
					    <label for="exampleInput1">请输入要查找的同事</label>
					    <input type="text" class="form-control" id="select_user_name" placeholder="请输入要查找的同事">
					  </div>
	            </div>
      <div class="modal-footer">
	                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	                <button type="button" id="btnSubmit" class="btn btn-primary" onclick="selectUser()">查找</button>
	            </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->



</body>
</html>